/**
 * 
 */
package guiTegoNieBedzie;


import java.util.LinkedList;

import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;



/**
 * @author fizyk
 *
 */
public abstract class FAbstractTableModel extends AbstractTableModel implements TableModel 
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 5965487331043839091L;
	protected String[] columnNames;
	protected LinkedList<?> data;
	protected AbstractDataObject temporarySelection;

	/* (non-Javadoc)
	 * @see javax.swing.table.TableModel#getColumnCount()
	 */
//	@Override
	public int getColumnCount() 
	{
		return this.columnNames.length;
	}

	/* (non-Javadoc)
	 * @see javax.swing.table.TableModel#getColumnName(int)
	 */
	@Override
	public String getColumnName( int columnIndex ) 
	{
		return this.columnNames[ columnIndex ];
	}

	/* (non-Javadoc)
	 * @see javax.swing.table.TableModel#getRowCount()
	 */
//	@Override
	public int getRowCount() 
	{
		return this.data.size();
	}

	/**
	 * check if rowIndex provided is the last row in table
	 * @param rowIndex
	 * @return 
	 */
	public boolean isLastRow( int rowIndex ) 
	{
		if( ( this.getRowCount() - 1 ) == rowIndex )
		{
			return true;
		}
		return false;
	}
	
	public AbstractDataObject getPreviousValue()
	{
		return temporarySelection;
	}

	/* (non-Javadoc)
	 * @see javax.swing.table.TableModel#getValueAt(int, int)
	 */
//	@Override
	abstract public Object getValueAt( int rowIndex, int colIndex );
	abstract public void setValueAt(Object cellValue, int rowIndex, int colIndex);
	abstract public void addRow();
	abstract public boolean isCellEditable(int rowIndex, int colIndex);
	

	public AbstractDataObject getRow(int rowIndex) 
	{
		return (AbstractDataObject) this.data.get( rowIndex );
	}

}
